<script type="text/javascript">
function backtolist() {
	window.location = '<?=base_url()?>admin/store/customer';
}
/*
function approved() {
	if (confirm('You want to approve this user as trading account?')) {
		var notify = $j('#notify:checked').val();
		var send = 0;
		if (notify) { send = 1; }
		$j.ajax({ 
			url: '<?=base_url()?>admin/store/approvetrader',
			type: 'POST',
			data: ({id:'<?=$user['id']?>',send:send}),
			dataType: "html",
			success: function(html) {
				window.location = '<?=base_url()?>admin/store/customer';
			}
		})	
	}
}
function pending() {
	if (confirm('You want to put this user to be pending?')) {
		$j.ajax({ 
			url: '<?=base_url()?>admin/store/pendingtrader',
			type: 'POST',
			data: ({id:'<?=$user['id']?>'}),
			dataType: "html",
			success: function(html) {
				window.location = '<?=base_url()?>admin/store/customer';
			}
		})	
	}
}
function deleteuser() {
	if (confirm('This action will delete this customers account, including all past orders related to this customer. Please note this action cannot be undone. If you don\'t wish to delete all past orders relating to this customer yet still want to deactivate the account click the pending button instead.')) {
		window.location = '<?=base_url()?>admin/store/deletecustomer/<?=$user['id']?>';
	}
}
*/
function addcustomer()
{
	if($j('#storeno').val() == '')
	{
		alert('Please enter store no');
		return false;
	}
	document.addcustomerForm.submit();
}
</script>
    	<div class="left">
        	<h1>Store Management</h1>
            <div class="bar">

            	<div class="text">Add New Customers</div>
            	<div class="cr"></div>
            </div>
            <div class="box">
            	<input type="button" class="button rounded" value="Back to Customers List" onClick="backtolist()" />
                <?php if($this->session->flashdata('add_successful')) { ?>
                <span class="green"> &nbsp; Customer has been added successfully!</span>
                <?php } ?>
            </div>
            <hr />
            
            <form method="post" action="<?=base_url()?>admin/store/addtrader" autocomplete="off" name="addcustomerForm">
          
            <div class="box bgw">
            	<h3>Business Details</h3>
                <dl class="three"><dt>Store No</dt><dd><input type="text" class="textfield rounded" name="storeno" id="storeno" /></dd></dl>
                <dl class="three"><dt>Store name</dt><dd><input type="text" class="textfield rounded" name="storename" id="storename" /></dd></dl>
                <dl class="three"><dt>Trading Name</dt><dd><input type="text" class="textfield rounded" name="tradingname" id="tradingname" /></dd></dl>
                <dl class="three"><dt>Franchisee</dt><dd><input type="text" class="textfield rounded" name="franchisee" id="franchisee" /></dd></dl>
                <dl></dl>
            </div>
            <hr />
            <div class="box">
                <h3>Contact Details</h3>
                <dl class="three"><dt>Address</dt><dd><input type="text" class="textfield rounded" name="address" id="address" /></dd></dl>
                <dl class="three"><dt>Suburb</dt><dd><input type="text" class="textfield rounded" name="suburb" id="suburb" /></dd></dl>
                 <dl class="three"><dt>Postcode</dt><dd><input type="text" class="textfield rounded" name="postcode" id="postcode" /></dd></dl>
                <dl class="three"><dt>State</dt><dd><select name="state" /><option value="Victoria">Victoria</option><option value="New South Wales">New South Wales</option>
                <option value="Australian Capital Territory">Australian Capital Territory</option><option value="Queensland">Queensland</option><option value="Northern Territory">Northern Territory</option><option value="South Australia">South Australia</option><option value="Western Australia">Western Australia</option><option value="Tasmania">Tasmania</option></select></dd></dl>
                <dl class="three"><dt>Country</dt><dd><select name="country"><?php foreach($countries as $c)
				{
					$selected = '';
					if($c['name'] == 'Australia')
					{
						$selected = "selected='selected'";
					}
					echo '<option value="'.$c['name'].'" '.$selected.'>'.$c['name'].'</option>';
				}?>
                </select></dd></dl>
                <dl></dl>
            </div>
            <hr />
            <!--
            <div class="box bgw">
            	<h3>Account Login</h3>
                <dl class="three"><dt>Username</dt><dd><b><?=$user['username']?></b></dd></dl>
                <dl class="three"><dt>Password</dt><dd><input type="password" class="textfield rounded" name="password" /></dd></dl>
                <dl class="three"><dt>Status</dt><dd>
                	<?php if($user['activated']) { ?>
                	<span class="green">Approved</span>
                	<?php } else { ?><span>Pending</span>
                	<?php } ?>
                </dd></dl>
                <dl></dl>
            </div>
            <hr />
            -->
            <div class="box bgw">
                <!--
            	<dl class="three"><dt>&nbsp;</dt>
            		<dd><label><input type="checkbox" id="notify" /> &nbsp; Send approval notification email to this user</label></dd>
            	</dl><dl></dl><br />
                -->
                <dl class="three">
                	<!--<dd><input type="submit" class="button rounded" value="Update" /></dd>
                	<dd><input type="button" class="button rounded" value="Approve" onClick="approved()" /></dd>
                	<dd><input type="button" class="button rounded" value="Pending" onClick="pending()" /></dd>-->
                	<dt><input type="button" class="button rounded" value="Add" onClick="javascript:addcustomer()" /></dt>
                	                    
                </dl>
                <dl></dl>
            </div>
            </form>
            
        </div>
        
